<?php


function stylesheet_tag($paths)
{
    $out = null;

    foreach ($paths as $path)
    {
       $out .= "\n\t<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"../stylesheets/{$path}\"/>\n";
    }
    
    return $out;
}

function javascript_tag($paths)
{

    $out = null;

    foreach ($paths as $path)
    {
        $out .=  "\n\t<script type=\"text/javascript\" src=\"../javascripts/{$path}\"></script>\n";
    }

    return $out;
}

function meta_tag_generator($program) {
    return "\n\t<meta name=\"generator\" content=\"{$program}\" />\n";
}

function meta_tag_author($name) {
    return "\n\t<meta name=\"author\" content=\"{$name}\" />\n";
}

function meta_tag_favicon($url="favicon.ico") {
    return "\n\t<link rel=\"shortcut icon\" href=\"../{$url}\" type=\"image/x-icon\" />\n";
}

function meta_tag_keyword($keywords) {
    return "\n\t<meta name=\"keywords\" content=\"{$keywords}\" />\n";
}

function meta_tag_description($text) {
    return "\n\t<meta name=\"description\" content=\"{$text}\" />\n";
}

function meta_tag_expires($datetime) {
    return "\n\t<meta http-equiv=\"expires\" content=\"{$datetime}\" />\n";
}


/*
*	 User Interface Functions by Orangeworks
*
* 	 Luiz Eduardo de Oliveira Fonseca -  orangeworks@orangeweb.com.br
*
*/

function link_to($text, $url, $attrs = null) {

    $a = null;

    $a .= "<a href=\"{$url}\" ";

    foreach ($attrs as $attr) {
        $a .= " {$attr[0]}=\"{$attr[1]}\" ";
    }

    $a .= ">{$text}</a>";

    return $a;

}





function list_tag($list_type, $items, $attrs, $item_selected = null, $item_selected_class = null) {

    $ul_tag = null;

    $li_tags = null;

    foreach ($attrs as $attr) {
        $ul_attr .= " {$attr[0]}=\"{$attr[1]}\" ";
    }

    $ul_tag = "<{$list_type} {$ul_attr} >";

    foreach ($items as $item) {

        if ($item == $item_selected) {
            $li_tags .= "<li class=\"{$item_selected_class}\">{$item}</li>";
        }
        else {
            $li_tags .= "<li>{$item}</li>";
        }
    }

    $ul_tag .= $li_tags;

    $ul_tag .= "</ul>";

    return $ul_tag;

}




function ul_list($items, $attrs, $item_selected = null, $item_selected_class = null) {
    return list_tag("ul", $items, $attrs, $item_selected, $item_selected_class);
}




function ol_list($items, $attrs, $item_selected = null, $item_selected_class = null) {
    return  list_tag("ol", $items, $attrs, $item_selected, $item_selected_class);
}





function image_tag($url, $attrs=null) {

    $tag_attr = null;

    foreach ($attrs as $attr => $value) {
        $tag_attr .= " {$attr}=\"{$value}\" ";
    }

    $img_tag = "<img src=\"..{$url}\" {$tag_attr} />";

    return $img_tag;

}



function site_root_uri() {
 $pageURL = 'http://';
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"];
 }
 return $pageURL;
}

function site_root_url() {
 $pageURL = 'http://';
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
 return $pageURL;
}


?>